package com.tcl.ribbon;

import com.netflix.client.ClientFactory;
import com.netflix.config.ConfigurationManager;
import com.netflix.loadbalancer.ILoadBalancer;
import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RoundRobinRule;
import com.netflix.loadbalancer.Server;

import java.io.IOException;

//@SpringBootApplication
public class Ribbon {
    public static void main(String[] args) throws IOException {
        ConfigurationManager.loadCascadedPropertiesFromResources("ribbon-client");
        ILoadBalancer loadBalancer = ClientFactory.getNamedLoadBalancer("MyRibbonClient");

        IRule chooseRule = new RoundRobinRule();

        chooseRule.setLoadBalancer(loadBalancer);

        for (int i = 0; i < 10; i++) {

            Server server = chooseRule.choose(null);

            System.out.println("request" + server.getHostPort());

        }

    }
}


